import 'package:date_format/date_format.dart';
import '../datetime_format.dart';

extension DateTimeExtension on DateTime {
  /// 日期ID，用于判断是否是同一天，2025-08-02 的 dayId 为 20250802
  int get dayId => day + month * 40 + ((year - 1900) * 600);

  ///是否是同一天
  bool isSameDay(DateTime other) {
    return day == other.day && month == other.month && year == other.year;
  }

  /// 2025-08-02 18:18:00
  String get normalStr {
    return DateUtil.formatDate(this);
  }

  /// 2025-08-02 18:18
  String get normalStrNotSecond {
    return DateUtil.formatDate(this, format: DateFormats.y_mo_d_h_m);
  }

  /// 2025年08月02日 18:18
  String get toZh_y_mo_d_h_m {
    return DateUtil.formatDate(this, format: DateFormats.zh_y_mo_d_h_m);
  }

  /// 2025-08-02
  String get toY_mo_d {
    return DateUtil.formatDate(this, format: DateFormats.y_mo_d);
  }

  /// 2025-08-02 18:18
  String get toY_mo_d_h_m {
    return DateUtil.formatDate(this, format: DateFormats.y_mo_d_h_m);
  }

  /// 2025-08-02 18:18:00
  String get toY_mo_d_h_m_s {
    return DateUtil.formatDate(this, format: DateFormats.y_mo_d_h_m_s);
  }

  /// 18:18
  String get toH_m {
    return DateUtil.formatDate(this, format: DateFormats.h_m);
  }

  /// 2025年08月02日
  String get toZh_y_mo_d {
    return DateUtil.formatDate(this, format: DateFormats.zh_y_mo_d);
  }

  /// 2025年08月02日 18时18分
  String get toZhFull {
    return DateUtil.formatDate(this, format: DateFormats.zh_full);
  }

  /// 2025-08-02 18:18:00.000
  String get toLogFull {
    return formatDate(this, [yyyy, '-', mm, '-', dd, ' ', HH, ':', nn, ':', ss, ".", SSS]);
  }

  /// 18:18:00.000
  String get toLogShort {
    return formatDate(this, [HH, ':', nn, ':', ss, ".", SSS]);
  }

  /// 20250802181800000
  String get toNumFull {
    return formatDate(this, [yyyy, '', mm, '', dd, '', HH, '', nn, '', ss, "", SSS]);
  }

  /// 250802181800000
  String get toNumFull2 {
    return formatDate(this, [yy, '', mm, '', dd, '', HH, '', nn, '', ss, "", SSS]);
  }

  /// 0802181800000
  String get toNumFull3 {
    return formatDate(this, [mm, '', dd, '', HH, '', nn, '', ss, "", SSS]);
  }

  /// 2025-08-02 18:18:00.000
  String format(String format) {
    return DateUtil.formatDate(this, format: format);
  }
}
